package cn.drenal.capcap.controller.forum;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.drenal.capcap.common.Response;
import cn.drenal.capcap.entity.Tag;
import cn.drenal.capcap.entity.vo.TagVO;
import cn.drenal.capcap.service.TagService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 前台标签控制器
 */
@RestController
@RequestMapping("/forum/tag")
@RequiredArgsConstructor
public class ForumTagController {

    private final TagService tagService;

    /**
     * 获取热门话题（标签）
     *
     * @return 标签列表
     */
    @SaIgnore
    @GetMapping("/hot-topics")
    public Response<List<TagVO>> getHotTopics() {
        return Response.success(tagService.getRandomTags());
    }
    /**
     * 获取标签list
     *
     * @return 标签列表
     */
    @SaIgnore
    @GetMapping("/list")
    public Response<List<Tag>> getTags() {
        return Response.success(tagService.list(new LambdaQueryWrapper<Tag>().eq(Tag::getStatus, 1)));
    }

    /**
     * 获取导航标签list
     *
     * @return 标签列表
     */
    @SaIgnore
    @GetMapping("/navList")
    public Response<List<Tag>> getNavTags() {
        return Response.success(tagService.list(new LambdaQueryWrapper<Tag>()
                .eq(Tag::getStatus, 1)
                .eq(Tag::getFixedNav, 1)));
    }
}
